﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Collections.Specialized;

namespace XEvents.Library.Targets
{
    public class FileDataReader: IDataReader
    {
        Dictionary<string, string> col_list;
        object[] objs;
        Hashtable ht;
        SqlDataReader dr;
        public FileDataReader(SqlServer server, string filename, string metafilename)
        {

        }

        //public int GetOrdinal(string name)
        //{
        //    Hashtable ht = new Hashtable();
        //    List<string> tough;

        //    tough.IndexOf(name);
        //    int i = 0;


        //    if (this._fieldNameLookup == null)
        //    {
        //        if (this.MetaData == null)
        //        {
        //            throw SQL.InvalidRead();
        //        }
        //        this._fieldNameLookup = new FieldNameLookup(this, this._defaultLCID);
        //    }
        //    return this._fieldNameLookup.GetOrdinal(name);
        //}

 


        //public object this[int i]
        //{
        //    get
        //    {
        //        return objs[i];
        //    }
        //}

        //public bool Read()
        //{
        //    if (dr.Read())
        //    {


        //        return true;
        //    }

        //    return false;
        //}


        #region IDataReader Implementation

        // Summary:
        //     Gets a value indicating the depth of nesting for the current row.
        //
        // Returns:
        //     The level of nesting.
        int Depth { get; }
        //
        // Summary:
        //     Gets a value indicating whether the data reader is closed.
        //
        // Returns:
        //     true if the data reader is closed; otherwise, false.
        bool IsClosed { get; }
        //
        // Summary:
        //     Gets the number of rows changed, inserted, or deleted by execution of the
        //     SQL statement.
        //
        // Returns:
        //     The number of rows changed, inserted, or deleted; 0 if no rows were affected
        //     or the statement failed; and -1 for SELECT statements.
        int RecordsAffected { get; }

        // Summary:
        //     Closes the System.Data.IDataReader Object.
        void Close();
        //
        // Summary:
        //     Returns a System.Data.DataTable that describes the column metadata of the
        //     System.Data.IDataReader.
        //
        // Returns:
        //     A System.Data.DataTable that describes the column metadata.
        //
        // Exceptions:
        //   System.InvalidOperationException:
        //     The System.Data.IDataReader is closed.
        DataTable GetSchemaTable();
        //
        // Summary:
        //     Advances the data reader to the next result, when reading the results of
        //     batch SQL statements.
        //
        // Returns:
        //     true if there are more rows; otherwise, false.
        bool NextResult();
        //
        // Summary:
        //     Advances the System.Data.IDataReader to the next record.
        //
        // Returns:
        //     true if there are more rows; otherwise, false.
        bool Read();

        #endregion

        #region IDataRecord Implementation
        // Summary:
        //     Gets the number of columns in the current row.
        //
        // Returns:
        //     When not positioned in a valid recordset, 0; otherwise, the number of columns
        //     in the current record. The default is -1.
        public int FieldCount
        {
            get
            {
                return col_list.Count;
            }
        }

        // Summary:
        //     Gets the column located at the specified index.
        //
        // Parameters:
        //   i:
        //     The zero-based index of the column to get.
        //
        // Returns:
        //     The column located at the specified index as an System.Object.
        //
        // Exceptions:
        //   System.IndexOutOfRangeException:
        //     The index passed was outside the range of 0 through System.Data.IDataRecord.FieldCount.
        public object this[int i] 
        {
            get
            {
                return objs[i];
            }
        }
        //
        // Summary:
        //     Gets the column with the specified name.
        //
        // Parameters:
        //   name:
        //     The name of the column to find.
        //
        // Returns:
        //     The column with the specified name as an System.Object.
        //
        // Exceptions:
        //   System.IndexOutOfRangeException:
        //     No column with the specified name was found.
        public object this[string name] 
        { 
            get
            {
                for (int i = 0; i<col_list.Count; i++)
                {
                   if col_list.ElementAt(
                }
            }
        }

        // Summary:
        //     Gets the value of the specified column as a Boolean.
        //
        // Parameters:
        //   i:
        //     The zero-based column ordinal.
        //
        // Returns:
        //     The value of the column.
        //
        // Exceptions:
        //   System.IndexOutOfRangeException:
        //     The index passed was outside the range of 0 through System.Data.IDataRecord.FieldCount.
        public bool GetBoolean(int i)
        {
            throw new NotImplementedException();
        }

        //
        // Summary:
        //     Gets the 8-bit unsigned integer value of the specified column.
        //
        // Parameters:
        //   i:
        //     The zero-based column ordinal.
        //
        // Returns:
        //     The 8-bit unsigned integer value of the specified column.
        //
        // Exceptions:
        //   System.IndexOutOfRangeException:
        //     The index passed was outside the range of 0 through System.Data.IDataRecord.FieldCount.
        public byte GetByte(int i)
        {
            throw new NotImplementedException();
        }

        //
        // Summary:
        //     Reads a stream of bytes from the specified column offset into the buffer
        //     as an array, starting at the given buffer offset.
        //
        // Parameters:
        //   i:
        //     The zero-based column ordinal.
        //
        //   fieldOffset:
        //     The index within the field from which to start the read operation.
        //
        //   buffer:
        //     The buffer into which to read the stream of bytes.
        //
        //   bufferoffset:
        //     The index for buffer to start the read operation.
        //
        //   length:
        //     The number of bytes to read.
        //
        // Returns:
        //     The actual number of bytes read.
        //
        // Exceptions:
        //   System.IndexOutOfRangeException:
        //     The index passed was outside the range of 0 through System.Data.IDataRecord.FieldCount.
        public long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length)
        {
            throw new NotImplementedException();
        }

        //
        // Summary:
        //     Gets the character value of the specified column.
        //
        // Parameters:
        //   i:
        //     The zero-based column ordinal.
        //
        // Returns:
        //     The character value of the specified column.
        //
        // Exceptions:
        //   System.IndexOutOfRangeException:
        //     The index passed was outside the range of 0 through System.Data.IDataRecord.FieldCount.
        public char GetChar(int i)
        {
            throw new NotImplementedException();
        }

        //
        // Summary:
        //     Reads a stream of characters from the specified column offset into the buffer
        //     as an array, starting at the given buffer offset.
        //
        // Parameters:
        //   i:
        //     The zero-based column ordinal.
        //
        //   fieldoffset:
        //     The index within the row from which to start the read operation.
        //
        //   buffer:
        //     The buffer into which to read the stream of bytes.
        //
        //   bufferoffset:
        //     The index for buffer to start the read operation.
        //
        //   length:
        //     The number of bytes to read.
        //
        // Returns:
        //     The actual number of characters read.
        //
        // Exceptions:
        //   System.IndexOutOfRangeException:
        //     The index passed was outside the range of 0 through System.Data.IDataRecord.FieldCount.
        public long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length)
        {
            throw new NotImplementedException();
        }

        //
        // Summary:
        //     Returns an System.Data.IDataReader for the specified column ordinal.
        //
        // Parameters:
        //   i:
        //     The index of the field to find.
        //
        // Returns:
        //     An System.Data.IDataReader.
        //
        // Exceptions:
        //   System.IndexOutOfRangeException:
        //     The index passed was outside the range of 0 through System.Data.IDataRecord.FieldCount.
        public IDataReader GetData(int i)
        {
            throw new NotImplementedException();
        }

        //
        // Summary:
        //     Gets the data type information for the specified field.
        //
        // Parameters:
        //   i:
        //     The index of the field to find.
        //
        // Returns:
        //     The data type information for the specified field.
        //
        // Exceptions:
        //   System.IndexOutOfRangeException:
        //     The index passed was outside the range of 0 through System.Data.IDataRecord.FieldCount.
        public string GetDataTypeName(int i)
        {
            throw new NotImplementedException();
        }

        //
        // Summary:
        //     Gets the date and time data value of the specified field.
        //
        // Parameters:
        //   i:
        //     The index of the field to find.
        //
        // Returns:
        //     The date and time data value of the specified field.
        //
        // Exceptions:
        //   System.IndexOutOfRangeException:
        //     The index passed was outside the range of 0 through System.Data.IDataRecord.FieldCount.
        public DateTime GetDateTime(int i)
        {
            throw new NotImplementedException();
        }

        //
        // Summary:
        //     Gets the fixed-position numeric value of the specified field.
        //
        // Parameters:
        //   i:
        //     The index of the field to find.
        //
        // Returns:
        //     The fixed-position numeric value of the specified field.
        //
        // Exceptions:
        //   System.IndexOutOfRangeException:
        //     The index passed was outside the range of 0 through System.Data.IDataRecord.FieldCount.
        public decimal GetDecimal(int i)
        {
            throw new NotImplementedException();
        }

        //
        // Summary:
        //     Gets the double-precision floating point number of the specified field.
        //
        // Parameters:
        //   i:
        //     The index of the field to find.
        //
        // Returns:
        //     The double-precision floating point number of the specified field.
        //
        // Exceptions:
        //   System.IndexOutOfRangeException:
        //     The index passed was outside the range of 0 through System.Data.IDataRecord.FieldCount.
        public double GetDouble(int i)
        {
            throw new NotImplementedException();
        }

        //
        // Summary:
        //     Gets the System.Type information corresponding to the type of System.Object
        //     that would be returned from System.Data.IDataRecord.GetValue(System.Int32).
        //
        // Parameters:
        //   i:
        //     The index of the field to find.
        //
        // Returns:
        //     The System.Type information corresponding to the type of System.Object that
        //     would be returned from System.Data.IDataRecord.GetValue(System.Int32).
        //
        // Exceptions:
        //   System.IndexOutOfRangeException:
        //     The index passed was outside the range of 0 through System.Data.IDataRecord.FieldCount.
        public Type GetFieldType(int i)
        {
            throw new NotImplementedException();
        }

        //
        // Summary:
        //     Gets the single-precision floating point number of the specified field.
        //
        // Parameters:
        //   i:
        //     The index of the field to find.
        //
        // Returns:
        //     The single-precision floating point number of the specified field.
        //
        // Exceptions:
        //   System.IndexOutOfRangeException:
        //     The index passed was outside the range of 0 through System.Data.IDataRecord.FieldCount.
        public float GetFloat(int i)
        {
            throw new NotImplementedException();
        }

        //
        // Summary:
        //     Returns the GUID value of the specified field.
        //
        // Parameters:
        //   i:
        //     The index of the field to find.
        //
        // Returns:
        //     The GUID value of the specified field.
        //
        // Exceptions:
        //   System.IndexOutOfRangeException:
        //     The index passed was outside the range of 0 through System.Data.IDataRecord.FieldCount.
        public Guid GetGuid(int i)
        {
            throw new NotImplementedException();
        }

        //
        // Summary:
        //     Gets the 16-bit signed integer value of the specified field.
        //
        // Parameters:
        //   i:
        //     The index of the field to find.
        //
        // Returns:
        //     The 16-bit signed integer value of the specified field.
        //
        // Exceptions:
        //   System.IndexOutOfRangeException:
        //     The index passed was outside the range of 0 through System.Data.IDataRecord.FieldCount.
        public short GetInt16(int i)
        {
            throw new NotImplementedException();
        }

        //
        // Summary:
        //     Gets the 32-bit signed integer value of the specified field.
        //
        // Parameters:
        //   i:
        //     The index of the field to find.
        //
        // Returns:
        //     The 32-bit signed integer value of the specified field.
        //
        // Exceptions:
        //   System.IndexOutOfRangeException:
        //     The index passed was outside the range of 0 through System.Data.IDataRecord.FieldCount.
        public int GetInt32(int i)
        {
            throw new NotImplementedException();
        }

        //
        // Summary:
        //     Gets the 64-bit signed integer value of the specified field.
        //
        // Parameters:
        //   i:
        //     The index of the field to find.
        //
        // Returns:
        //     The 64-bit signed integer value of the specified field.
        //
        // Exceptions:
        //   System.IndexOutOfRangeException:
        //     The index passed was outside the range of 0 through System.Data.IDataRecord.FieldCount.
        public long GetInt64(int i)
        {
            throw new NotImplementedException();
        }

        //
        // Summary:
        //     Gets the name for the field to find.
        //
        // Parameters:
        //   i:
        //     The index of the field to find.
        //
        // Returns:
        //     The name of the field or the empty string (""), if there is no value to return.
        //
        // Exceptions:
        //   System.IndexOutOfRangeException:
        //     The index passed was outside the range of 0 through System.Data.IDataRecord.FieldCount.
        public string GetName(int i)
        {
            throw new NotImplementedException();
        }

        //
        // Summary:
        //     Return the index of the named field.
        //
        // Parameters:
        //   name:
        //     The name of the field to find.
        //
        // Returns:
        //     The index of the named field.
        public int GetOrdinal(string name)
        {
            throw new NotImplementedException();
        }

        //
        // Summary:
        //     Gets the string value of the specified field.
        //
        // Parameters:
        //   i:
        //     The index of the field to find.
        //
        // Returns:
        //     The string value of the specified field.
        //
        // Exceptions:
        //   System.IndexOutOfRangeException:
        //     The index passed was outside the range of 0 through System.Data.IDataRecord.FieldCount.
        public string GetString(int i)
        {
            throw new NotImplementedException();
        }

        //
        // Summary:
        //     Return the value of the specified field.
        //
        // Parameters:
        //   i:
        //     The index of the field to find.
        //
        // Returns:
        //     The System.Object which will contain the field value upon return.
        //
        // Exceptions:
        //   System.IndexOutOfRangeException:
        //     The index passed was outside the range of 0 through System.Data.IDataRecord.FieldCount.
        public object GetValue(int i)
        {
            throw new NotImplementedException();
        }

        //
        // Summary:
        //     Gets all the attribute fields in the collection for the current record.
        //
        // Parameters:
        //   values:
        //     An array of System.Object to copy the attribute fields into.
        //
        // Returns:
        //     The number of instances of System.Object in the array.
        public int GetValues(object[] values)
        {
            throw new NotImplementedException();
        }

        //
        // Summary:
        //     Return whether the specified field is set to null.
        //
        // Parameters:
        //   i:
        //     The index of the field to find.
        //
        // Returns:
        //     true if the specified field is set to null; otherwise, false.
        //
        // Exceptions:
        //   System.IndexOutOfRangeException:
        //     The index passed was outside the range of 0 through System.Data.IDataRecord.FieldCount.
        public bool IsDBNull(int i)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region IDisposable Implementation
        // Summary:
        //     Performs application-defined tasks associated with freeing, releasing, or
        //     resetting unmanaged resources.
        void Dispose();

        #endregion

    }
}
